{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "gpuType": "T4"
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "#MedViTV2\n",
        "\n",
        "For training and evaluating the model, it is recommended to use a GPU due to the high computational requirements.\n",
        "\n"
      ],
      "metadata": {
        "id": "tkLRozn-R7Jc"
      }
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "GWVjvYZsQkJv"
      },
      "outputs": [],
      "source": [
        "!nvidia-smi"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "pip install torch==2.5.0 torchvision==0.20.0 torchaudio==2.5.0 --index-url https://download.pytorch.org/whl/cu124"
      ],
      "metadata": {
        "id": "GYldV-JE8s7f"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "!pip3 install natten==0.17.3+torch250cu124 -f https://shi-labs.com/natten/wheels/"
      ],
      "metadata": {
        "id": "sSx_WBGT8wMe"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "To get started, clone the repository and navigate to the project directory:"
      ],
      "metadata": {
        "id": "IsRIXm8dS2sv"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "!git clone https://github.com/Omid-Nejati/MedViTV2.git\n",
        "%cd /content/MedViTV2"
      ],
      "metadata": {
        "id": "ufa7cY1qQ0G7"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "!pip install -r requirements.txt"
      ],
      "metadata": {
        "id": "BvriJR9GQ-DW"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "### 🧠 Train Different Versions of MedViT on 17 Datasets  \n",
        "\n",
        "You can easily train different versions of MedViT by specifying the model and dataset names:  \n",
        "\n",
        " 🔹 **Model Selection:**  \n",
        "```bash\n",
        "--model_name [MedViT_tiny, MedViT_small, MedViT_base, MedViT_large]\n",
        "\n"
      ],
      "metadata": {
        "id": "bi7saJl1WC6B"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "  \n",
        "\n",
        " 📊 **Dataset Selection:**  \n",
        "```bash\n",
        "--dataset [tissuemnist, pathmnist, chestmnist, dermamnist, octmnist,\n",
        "           pneumoniamnist, retinamnist, breastmnist, bloodmnist,\n",
        "           organamnist, organcmnist, organsmnist, Kvasir, CPN,\n",
        "           Fetal, PAD, ISIC2018]\n",
        "\n"
      ],
      "metadata": {
        "id": "lbtljHDGaz-O"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "!!!! The process of downloading the dataset for the first time may take a while, so please be patient. 😊"
      ],
      "metadata": {
        "id": "cw4d_lfOfMRP"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "!python main.py --model_name 'MedViT_large' --dataset 'breastmnist' --pretrained False"
      ],
      "metadata": {
        "id": "fWcaCqoSRxSI"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "###Train timm models\n",
        "🤯 You can easily train any model from TIMM on each dataset by simply changing the model name. If a pre-trained version is available, you can enable it by setting the corresponding flag to True.\n",
        "\n",
        "link: https://timm.fast.ai/"
      ],
      "metadata": {
        "id": "xMAbuPhkcxsO"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "!python main.py --model_name 'resnet34' --dataset 'octmnist' --pretrained True"
      ],
      "metadata": {
        "id": "P5HPMa32RI0n"
      },
      "execution_count": null,
      "outputs": []
    }
  ]
}